import axios from '@/libs/api.request'

export const login = ({ userName, password }) => {
  // const data = {
  //   userName: userName,
  //   userPassword: password
  // }
  return axios.request({
    url: `login?userName=${userName}&userPassword=${password}`,
    method: 'post'
  })
}

export const getUserInfo = (token) => {
  return axios.request({
    url: 'user/getUserInfo',
    method: 'get'
  })
}

export const logout = (token) => {
  return axios.request({
    url: 'user/logout',
    method: 'get'
  })
}

export const getUnreadCount = () => {
  return axios.request({
    url: 'message/count',
    method: 'get'
  })
}
// 首页信息
export const getHomeInfo = () => {
  return axios.request({
    url: 'admin/home/rpt',
    method: 'post'
  })
}
// 首页底部报表
export const getHomerpt = () => {
  return axios.request({
    url: '/admin/home/docrpt',
    method: 'post'
  })
}
export const getMessage = () => {
  return axios.request({
    url: 'message/init',
    method: 'get'
  })
}

export const getContentByMsgId = (msg_id) => {
  return axios.request({
    url: 'message/content',
    method: 'get',
    params: {
      msg_id
    }
  })
}

export const hasRead = (msg_id) => {
  return axios.request({
    url: 'message/has_read',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const removeReaded = (msg_id) => {
  return axios.request({
    url: 'message/remove_readed',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const restoreTrash = (msg_id) => {
  return axios.request({
    url: 'message/restore',
    method: 'post',
    data: {
      msg_id
    }
  })
}
